//
//  MyMusicTableViewController.m
//  TthMusic
//
//  Created by lanou3g on 15/9/3.
//  Copyright (c) 2015年 陶天海. All rights reserved.
//

#import "MyCollectionsController.h"

@interface MyCollectionsController ()

@end

@implementation MyCollectionsController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    BlurImageView *blurimageView = [[BlurImageView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.tableView.backgroundView = blurimageView;
    UIImage * image = [[UIImage imageNamed:@"backimage"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIBarButtonItem * leftItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(clickLeft:)];
    self.navigationItem.leftBarButtonItem = leftItem;
    self.tableView.separatorStyle =  0;
    
    [self.tableView registerClass:[MyCollectionCell class] forCellReuseIdentifier:@"myCollectionCell"];
    
   
    
    
    
    
    
    
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)clickLeft:(UIBarButtonItem *)button {
    
    [self dismissViewControllerAnimated:NO completion:nil];
    
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 4;
}







- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    NSArray * arr = @[@"星座收藏࿐",@"笑话收藏࿐",@"趣图收藏࿐",@"清除缓存࿐"];
   MyCollectionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myCollectionCell" forIndexPath:indexPath];
    
    // Configure the cell...
    cell.showLabelOne.text = arr[indexPath.row];
    
    
   
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {



    return kWidth/3.5;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        FortuneCollectionViewController *FortuneVC = [[FortuneCollectionViewController alloc] initWithCollectionViewLayout:layout];
        [self.navigationController pushViewController:FortuneVC animated:YES];
    }else if(indexPath.row == 1) {
        MyJokeViewController *MyJokeVC = [[MyJokeViewController alloc] init];
     
        [self.navigationController pushViewController:MyJokeVC animated:YES];
    }else if(indexPath.row == 2) {
    
        MyPicTableViewController *PicVC = [[MyPicTableViewController alloc] init];
        [self.navigationController pushViewController:PicVC animated:YES];
    
   }
    else if(indexPath.row == 3){
        
        [[SDImageCache sharedImageCache] clearDisk];//清除磁盘缓存
        [[SDImageCache sharedImageCache] clearMemory];//清除内存缓存
        NSLog(@"缓存清除完毕");
        
        //显示alertView提示用户
        UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"清除缓存完毕!" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
        [alertView show];
        //0.3秒后alertView消失
        [self performSelector:@selector(p_removeAlertView:) withObject:alertView afterDelay:0.3];

}


}

- (void)p_removeAlertView:(UIAlertView *)alertView
{
    //alertView消失
    [alertView dismissWithClickedButtonIndex:0 animated:YES];
    
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
